﻿using Hzt_WebApi;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebHzt_Api.Models.Database;

namespace WebHzt_Api.service
{
    public class VoteService:IVoteService
    {
        private readonly IDatabase _redis;
        private readonly Hzt_WebApiContext _db;
        public VoteService(RedisHelper redisHelper, Hzt_WebApiContext db)
        {
            _redis = redisHelper.GetDatabase();
            _db = db;
        }
        /// <summary>
        /// 投票接口
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="VoteId"></param>
        public void AddVoteRedis(string userId, int VoteId)
        {
            //在Hash数据里找有没有键名数据(商品ID)
            //找到的话，键值+1
            //找不到 创建这个键名：商品I的 键值：1
            var key = "Uservote" + userId;//UserCar14
            _redis.HashIncrement(key, VoteId);

        }

    }
}
